*******************************************************************************
*** Purpose: Submission Analysis
*** Date: 8/19/20
*** Author: Ross Butters
*** Data: 2000 ANES and 2016 CCES combined 
*******************************************************************************

cd "/Users/rossbutters/Documents/UC-Davis/Courses/Research/Networks Over Time/POBE Publication/"

clear

set more off 

use "Combined_ANES_all_CCES.dta"

//Figure 1 - homogeneity
// Number of Bush/Trump discussants in Bush/Trump voter networks
twoway (hist dbush if vote_r==1&hsum>=1&anes==1, discrete percent color(gs10) lpattern(none)) /// 
	(hist dtrump if vote_r==1&hsum>=1&anes==0, discrete percent fcolor(none)), ///
	xscale(range(0 3)) xtitle("Reported Number of Discussants Voting for Bush or Trump", size(medlarge)) ///
	xlabel(0"0" 1 "1" 2 "2" 3 "3") ytitle("Percent of GOP Voters per Year", size(medlarge)) ///
	title("Percent of GOP Voters by Number of GOP Dicussants", size(large)) legend(order(1 "ANES 2000" 2 "CCES 2016" )) /// 
	name(gopvoters_gop, replace)
graph export gopvoters_gop.pdf, replace	


// Number of Gore/Clinton discussants in Gore/Clinton voter networks
twoway (hist dgore if vote_r==-1&hsum>=1&anes==1, discrete percent color(gs10) lpattern(none)) /// 
	(hist dclinton if vote_r==-1&hsum>=1&anes==0, discrete percent fcolor(none)), ///
	xscale(range(0 3)) xtitle("Reported Number of Discussants Voting for Gore or Clinton", size(medlarge)) ///
	xlabel(0"0" 1 "1" 2 "2" 3 "3") ytitle("Percent of Dem Voters per Year", size(medlarge)) ///
	title("Percent of Dem Voters by Number of Dem Discussants", size(large)) legend(order(1 "ANES 2000" 2 "CCES 2016" )) ///
	name(demvoters_dem, replace)
graph export demvoters_dem.pdf, replace	


// Figure 2 - heterogeneity 
// Number of Bush/Trump Discussants in Gore/Clinton voter networks 
twoway (hist dbush if vote_r==-1&hsum>=1&anes==1, discrete percent color(gs10) lpattern(none)) /// 
	(hist dtrump if vote_r==-1&hsum>=1&anes==0, discrete percent fcolor(none)), ///
	xscale(range(0 3)) xtitle("Reported Number of Discussants Voting for Bush or Trump", size(medlarge)) ///
	xlabel(0"0" 1 "1" 2 "2" 3 "3") ytitle("Percent of Dem Voters per Year", size(medlarge)) ///
	title("Percent of Dem Voters by Number of GOP Discussants", size(large)) legend(order(1 "ANES 2000" 2 "CCES 2016" )) ///
	name(demvoters_gop, replace)
graph export demvoters_gop.pdf, replace	
	
	
	
// Number of Gore/Clinton Discussants in Bush/Trump voter networks 
twoway (hist dgore if vote_r==1&hsum>=1&anes==1, discrete percent color(gs10) lpattern(none)) /// 
	(hist dclinton if vote_r==1&hsum>=1&anes==0, discrete percent fcolor(none)), ///
	xscale(range(0 3)) xtitle("Reported Number of Discussants Voting for Gore or Clinton", size(medlarge)) ///
	xlabel(0"0" 1 "1" 2 "2" 3 "3") ytitle("Percent of GOP Voters per Year", size(medlarge)) ///
	title("Percent of GOP Voters by Number of Dem Discussants", size(large)) legend(order(1 "ANES 2000" 2 "CCES 2016" ))	 ///
	name(gopvoters_dem, replace)
graph export gopvoters_dem.pdf, replace	


	
	
//////////////////////////////////////////////////////////////////////////////
/////////// Proportion Network Negative Binomial Table 1 and Figure 3
//////////////////////////////////////////////////////////////////////////////

// DV: Proportion of Gore Supporters 
glm dgoreprop per_dem_2000 pid pidfold education interest ideo age white black latino income female maritalstat if hsum>=1&anes==1, link(logit) family(binomial) robust

// predicted prob for respondent in 30% DEM county
margins, at(pid==(-3(1)3) per_dem_2000=(30)) atmeans vsquish post
est store dem2000_30

// predicted prob for respondent in 70% DEM county
glm dgoreprop per_dem_2000 pid pidfold education interest ideo age white black latino income female maritalstat if hsum>=1&anes==1, link(logit) family(binomial) robust
margins, at(pid==(-3(1)3) per_dem_2000=(70)) atmeans vsquish post
est store dem2000_70


// DV: Proportion of Clinton Supporters 
glm dclintonprop per_dem_2016 pid pidfold education interest ideo age white black latino faminc female maritalstat if hsum>=1&anes==0, link(logit) family(binomial) robust

// predicted prob for respondent in 30% DEM county
margins, at(pid==(-3(1)3) per_dem_2016=(30)) atmeans vsquish post
est store dem2016_30

// predicted prob for respondent in 70% DEM county
glm dclintonprop per_dem_2016 pid pidfold education interest ideo age white black latino faminc female maritalstat if hsum>=1&anes==0, link(logit) family(binomial) robust
margins, at(pid==(-3(1)3) per_dem_2016=(70)) atmeans vsquish post
est store dem2016_70



// DV: Proportion of Bush Supporters 
glm dbushprop per_gop_2000 pid pidfold education interest ideo age white black latino income female maritalstat if hsum>=1&anes==1 , link(logit) family(binomial) robust

// DV: Proportion of Trump Supporters 
glm dtrumpprop per_gop_2016 pid pidfold education interest ideo age white black latino faminc female maritalstat if hsum>=1&anes==0, link(logit) family(binomial) robust





// Figure 3 - predicted proportion of supporters
// Predicted proportion of DEM discussants in DEM counties (30 and 70)
coefplot dem2000_30 dem2016_30, at ///
	title("30 Percent Support for Democrat Candidate") ///
	ytitle(Predicted Proportion of Dem Supporters) ylabel(0(.2)1) /// 
	xtitle(Respondent Party Identification) xtick(-3(1)3) ///
	xlabel(-3 `" "Strong" "Dem." "' 0 "Independent" 3 `" "Strong" "Rep." "') ///
	legend(row(1) order(1 "ANES 2000" 2 "CCES 2016")) ///
	noci lwidth(*1) connect(l) name(DEM30, replace)
graph export DEM30.pdf, replace

	
coefplot dem2000_70 dem2016_70, at ///
	title("70 Percent Support for Democrat Candidate") ///
	ytitle(Predicted Proportion of Dem Supporters) ylabel(0(.2)1) /// 
	xtitle(Respondent Party Identification) xtick(-3(1)3) ///
	xlabel(-3 `" "Strong" "Dem." "' 0 "Independent" 3 `" "Strong" "Rep." "') ///
	legend(row(1) order(1 "ANES 2000" 2 "CCES 2016")) ///
	noci lwidth(*1) connect(l) name(DEM70, replace)
graph export DEM70.pdf, replace
	

